// 云函数入口文件
const cloud = require('wx-server-sdk')

cloud.init({
  env: "coursetest-4gdpfc295ac4eaea"
})

// 云函数入口函数
exports.main = async (event, context) => {
  const wxContext = cloud.getWXContext()

  let ret = null
  switch (event.type) {
    case "add":
      ret = event.a + event.b
      break;

    case "mul":
      ret = event.a * event.b
      break;

    default:
      break;
  }

  return {
    operation:event.type,
    ret
  }

  // return {
  //   event,
  //   openid: wxContext.OPENID,
  //   appid: wxContext.APPID,
  //   unionid: wxContext.UNIONID,
  //   prod: event.a * event.b
  // }
}